/*
 * EasyBounceGameContainer.h
 *
 *  Created on: 2009-3-14
 *      Author: Wayne
 */

#ifndef EASYBOUNCEGAMECONTAINER_H_
#define EASYBOUNCEGAMECONTAINER_H_

// INCLUDES
#include <coecntrl.h>
#include <aknlists.h>
#include <AknsBasicBackgroundControlContext.h>

#include "coedef.h"
#include "GameObserver.h"
/**
*  container control class.
*  
*/
class CEasyBounceGameContainer : public CCoeControl, MCoeControlObserver, public MGameObserver
    {
    public: // Constructors and destructor

    	static CEasyBounceGameContainer* NewL();

        /**
        * Destructor.
        */
        ~CEasyBounceGameContainer();
        
        /*!
          @function OfferKeyEventL

          @discussion Handles key events.
          @param aKeyEvent The key event.
          @param aType The type of key event: EEventKey, EEventKeyUp or EEventKeyDown.
          @result Indicates whether or not the key event was used by this control.
          */
        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
    
    public: // from MGameObserver
    	void GameChanged( CEngine* aGame );
    	void GameOver( CEngine* aGame );
    	void GamePaused( CEngine* aGame );
    	
	
    private: // Functions from base classes
    	
    	CEasyBounceGameContainer();
        /**
        * EPOC default constructor.
        * @param aRect Frame rectangle for container.
        */
        void ConstructL();
        /**
         * From CoeControl,SizeChanged.
         */
        void SizeChanged();

        /**
         * From CoeControl,CountComponentControls.
         */
        TInt CountComponentControls() const;

        /**
         * From CCoeControl,ComponentControl.
         */
        CCoeControl* ComponentControl(TInt aIndex) const;

        /**
         * From CCoeControl,Draw.
         */
        void Draw(const TRect& aRect) const;

        /**
         * From CCoeControl, HandleControlEventL.
         */
        // event handling section
        // e.g Listbox events
        void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
        
        /**
         * From CCoeContro, HandlePointerEventL
         */
        void HandlePointerEventL(const TPointerEvent& aPointerEvent);
        
        /**
        * From CCoeControl, HandleResourceChange
        */
        void HandleResourceChange(TInt aType);
        
        /**
         * For the usage of skin support
         */
        TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
        
        /*
         * caculate all the control layout
         */
        void CaculateLayout();
        
        
    private: //data
    	CEikImage* iWoodenBall;
    	CFbsBitmap* iBall, *iBallMask;
    	TPoint iLineStart, iLineEnd;
    	TRect iModelRect;
    	
    	//to enable skin support for the application
    	CAknsBasicBackgroundControlContext* iBgContext;
    	
    public: 
    	enum TControls
    		{
    		EWoodenBallImage,
    		ELastControl
    		};
    };

#endif /* EASYBOUNCEGAMECONTAINER_H_ */
